package com.job.common.converter;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.job.common.Constant;
import com.job.mapper.UserMapper;
import com.job.pojo.Student;
import com.job.pojo.User;
import com.job.pojo.vo.StudentVO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;

@Component
public class StudentFieldConverter {

    @Resource
    private UserMapper userMapper;

    private static final HashMap<Integer,String> xlMap = new HashMap<Integer,String>(){{
        put(0,"大专");
        put(1,"本科");
        put(2,"研究生");
        put(3,"博士");
    }};

    private static final HashMap<Integer,String> workTimeMap = new HashMap<Integer,String>(){{
        put(0,"本周到岗");
        put(1,"月内到岗");
        put(2,"三个月内到岗");
    }};



    public  StudentVO studentPoToVo(Student student){

        LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(User::getUserType, Constant.STUDENT)
                .eq(User::getRoleId, student.getStudentId());
        User user = userMapper.selectOne(wrapper);


        StudentVO studentVO = new StudentVO();
        studentVO.setStudentId(student.getStudentId());
        studentVO.setStudentName(student.getStudentName());
        studentVO.setCreateTime(student.getCreateTime());
        studentVO.setPosition(student.getPosition());
        studentVO.setFile(student.getFile());
        studentVO.setSalary(student.getSalary());
        studentVO.setMajor(student.getMajor());
        studentVO.setXl(xlMap.get(student.getXl()));
        studentVO.setPhone(student.getPhone());
        studentVO.setSchool(student.getSchool());
        studentVO.setWechat(student.getWechat());
        studentVO.setWorkTime(workTimeMap.get(student.getWorkTime()));
        studentVO.setSuperiority(student.getSuperiority());
        studentVO.setUserId(user.getId());
        return studentVO;
    }
}
